import os, shutil, pathlib

original_dir  = os.walk("./JPEGImages")
new_base_dir = pathlib.Path("./")

def make_subset(subset_name, start_index, end_index):
    dir = new_base_dir / subset_name 
    os.makedirs(dir)
    for root, dirs, files in original_dir:
        for i,file in enumerate(files):
            if i<start_index:
                continue
            if i>=end_index:
                break
            img_path = os.path.join(root, file)
            img_path = pathlib.Path(img_path)
            shutil.copyfile(src=img_path, dst=dir / file)
        break

# make_subset("JPEGImages_1", start_index=0, end_index=619)
# make_subset("JPEGImages_2", start_index=620, end_index=1239)
make_subset("JPEGImages_3", start_index=1240, end_index=1861)